-module(ebiz_json).
-include("rec_dec.hrl").
-export([api/3]).
api(queue,list,L) ->
	Vendor_Id = (session_service:getLoginRec(
											tools:get_param(L,"_inter_session_id","undefined")
											)
				)#login_rec.vendor_id,
	io:format("get queue list for vendor ~p~n",[Vendor_Id]),
	vendor_adapter:get_queue_inst_list(json,(Vendor_Id));


api(queue,detail,L) ->
	Vendor_Id = (session_service:getLoginRec(
											tools:get_param(L,"_inter_session_id","undefined")
											)
				)#login_rec.vendor_id,
	{"id",Queue_Id} = lists:keyfind("id",1,L),
    queue_adapter:detail(Vendor_Id,list_to_binary(Queue_Id));

api(queue,delete,L) ->
	{value,{"name",Name}} = lists:keysearch("name",1,L),
    queue_json:delete(Name);
api(user,get,L) ->
	user_adapter:get(json,L);
api(vendor,get,L) ->
	vendor_adapter:get(L);
api(queue,add_cust,L) ->
	Vendor_Id = (session_service:getLoginRec(
											tools:get_param(L,"_inter_session_id","undefined")
											)
				)#login_rec.vendor_id,
	{"id",Queue_Id} = lists:keyfind("id",1,L),
	{"json_data",Cust} = lists:keyfind("json_data",1,L),
	queue_adapter:add_cust(Vendor_Id,list_to_binary(Queue_Id),Cust);
	
api(queue,get,L) ->
	queue_adapter:get(L).